﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq.Expressions;
using Newtonsoft.Json.Linq;
using WebGrease.Css.Extensions;

using CanDoo;
using CanDoo.Core;
using CanDoo.Data;
using CanDoo.Web;
using CanDoo.FineUI;
using CanDoo.Extensions;
using CanDoo.Oil.Core.Models;
using CanDoo.Oil.Core.Contracts;
using CanDoo.Admin.Core.Contracts;
using CanDoo.Core.Data;
using FineUIPro;

namespace CanDoo.Oil.WebApp.APIAPIOperateLog
{
    public partial class AdminDebug : ListPageBase<IAPIOperateLogContract, APIOperateLog>
    {


        public IOilSalesSerialNumContract OilSalesSerialNumContract { get; set; }
        public IOilSerialNumContract OilSerialNumContract { get; set; }

        #region 方法
        protected override void InitGrid()
        {
            Selector = p => new
            {
                p.OilSalerNo,
                p.OilSalesSerialNum,
                p.OilSalesSerialNumId,
                p.OilPort,
                p.OilSerialNum,
                p.OilSerialNumId,
                p.CustomMoneyLast,
                p.BatchNo,
                p.OpreateTime,
                p.OperateType,
                p.OilOutPut,
                p.Before,
                p.Last,
                p.Price,
                p.Money,
                p.UpdateTime,
                p.Operater,
                p.Token,
                p.Customer,
                p.Id,
                p.Name
            };
            base.InitGrid();
        }

        protected override void Search()
        {
            var key = SearchKey.GetValue();
            //var oilsalesserialnumId = SearchOilSalesSerialNum.GetValue().ToLong();
            //var oilserialnumId = SearchOilSerialNum.GetValue().ToLong();
            if (string.IsNullOrEmpty(key) == false)
            {
                Filter = Filter.And(p => p.Name.Contains(key) || p.OilSalesSerialNum.TerminalNum.Contains(key) || p.OilSalesSerialNum.SerialNumber.Contains(key) || p.Customer.CardNo.Contains(key));
            }
            //if (oilsalesserialnumId >  0L)
            //    Filter = Filter.And(p => p.OilSalesSerialNumId == oilsalesserialnumId);
            //if (oilserialnumId >  0L)
            //    Filter = Filter.And(p => p.OilSerialNumId == oilserialnumId);

            Filter = Filter.And(p => p.OperateType == 14);
        }
        #endregion

        #region 事件
        #region Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //FineUIListHelper.BindDDL<OilSalesSerialNum>("售油机",OilSalesSerialNumContract.GetResolvedTree(), 0L, SearchOilSalesSerialNum);
                //FineUIListHelper.BindDDL(OilSalesSerialNumContract.EntityName, this.OilSalesSerialNumContract.GetSelectList(), 0L, SearchOilSalesSerialNum);
                //FineUIListHelper.BindDDL<OilSerialNum>("关联哪桶油",OilSerialNumContract.GetResolvedTree(), 0L, SearchOilSerialNum);
                //FineUIListHelper.BindDDL(OilSerialNumContract.EntityName, this.OilSerialNumContract.GetSelectList(), 0L, SearchOilSerialNum);
                InitGrid();
            }
        }
        #endregion

        #endregion 事件

    }
}
